package cn.hnevc.xiaoming;

// 银行类

public class Bank {

	static String bankName; // 定义静态变量银行名称
	private String name; // 储户姓名
	private String password; // 密码
	private double balance; // 账户余额
	private double turnover; // 交易额
	// 静态方法，打印输出银行欢迎语句

	static void welcome() {
		System.out.println("欢迎来到" + bankName + "-------------");
	}

	// 构造方法，开户
	public Bank(String name, String password, double turnover, double balance) {
		this.name = name;
		this.password = password;
		this.turnover = turnover - 10;
		System.out.println(name + "开户成功，账户余额" + balance);
	}
	//将验证的密码抽成一个
	private void checkPassWord(String password) {
		if (this.password != password) {
			System.out.println("您输入的密码错误，请重新输入！");
			return;
		}
	}

	// 存款
	public void deposit(String password, double turnover) {
		this.checkPassWord(password);
		balance = balance + turnover;
		System.out.println(name + "您好！您的帐户已存入" + turnover + "元，" + "当前余额为" + balance);
	}

	// 取款
	public void withdrawal(String password, double turnover) {
		// 验证帐号密码是否正确
		this.checkPassWord(password);
		// 验证当前交易是否大于存款
		if (balance - turnover > 0) {
			balance = balance - turnover;
			System.out.println(name + "您好，您的账户已取出" + turnover + "元，" + "当余额为" + balance + "元");
		} else {
			System.out.println("对不起，账户余额不足！");
		}
	}

	// 静态方法，打印出银行欢迎下次光临语句
	static void welcomeNext() {
		System.out.println("请携带好随身物品，欢迎下次光临");
	}
}

